const Koa = require('koa');
const router = require('koa-router')();
const {readFileSync} = require('fs');

class Server {
    #clientHTML = readFileSync(`${__dirname}/index.html`)

    index = ctx => {
        // ctx.set({'Content-Type': 'text/html'});
        ctx.type = 'html';
        ctx.body = this.#clientHTML
    }

    constructor() {
        const app = new Koa()

        router.get('/', this.index)

        const port = 3080
        app
            .use(router.routes())
            .listen(
                port,
                _ => console.log(`Server running on http://localhost:${port}`));
    }
}

new Server();
